﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Kevin.Framework.Data.OrmMapping;
using Kevin.Framework.Data.Query;
using Kevin.Framework.Validation;

namespace JOIN.Rights.Model
{
    //TU_Company
    [Serializable]
    [TableMapping("TU_Company")]
    public class CompanyInfo : EntityBase
    {
        #region Constructor

        public CompanyInfo()
            : this("")
        { }
        public CompanyInfo(string connectionKey)
            : base(connectionKey)
        { }

        #endregion

        #region Methods

        public CompanyInfo Load()
        {
            List<CompanyInfo> list = this.SelectedByProperties<CompanyInfo>();
            return list[0];
        }

        static CompanyInfo _instance;
        public static CompanyInfo Instance
        {

            get
            {
                if (_instance == null)
                {
                    return new CompanyInfo();
                }
                else
                {
                    return _instance;
                }
            }
        }

        #endregion

        #region Properties

        private string _id;

        public static QueryColumn _ID = new QueryColumn("ID", DbType.String);
        /// <summary>
        /// 唯一键
        /// </summary>		
        [FieldMapping("ID",PrimaryKey=true)]
        public string ID
        {
            get
            {
                return _id;
            }
            set
            {
                if (_id != value)
                {
                    base.OnPropertyChanged("ID", _id, value);
                    _id = value;
                }
            }
        }

        private string _companyid;

        public static QueryColumn _CompanyID = new QueryColumn("CompanyID", DbType.String);
        /// <summary>
        /// 企业编码
        /// </summary>		
        [FieldMapping("CompanyID")]
        [NotNullValidator(MessageTemplate = "企业编码不能为空")]
        public string CompanyID
        {
            get
            {
                return _companyid;
            }
            set
            {
                if (_companyid != value)
                {
                    base.OnPropertyChanged("CompanyID", _companyid, value);
                    _companyid = value;
                }
            }
        }

        private string _companyname;

        public static QueryColumn _CompanyName = new QueryColumn("CompanyName", DbType.String);
        /// <summary>
        /// 企业名称
        /// </summary>		
        [FieldMapping("CompanyName")]
        [NotNullValidator(MessageTemplate = "企业名称不能为空")]
        public string CompanyName
        {
            get
            {
                return _companyname;
            }
            set
            {
                if (_companyname != value)
                {
                    base.OnPropertyChanged("CompanyName", _companyname, value);
                    _companyname = value;
                }
            }
        }

        private string _address;

        public static QueryColumn _Address = new QueryColumn("Address", DbType.String);
        /// <summary>
        /// 地址
        /// </summary>		
        [FieldMapping("Address")]
        public string Address
        {
            get
            {
                return _address;
            }
            set
            {
                if (_address != value)
                {
                    base.OnPropertyChanged("Address", _address, value);
                    _address = value;
                }
            }
        }

        private string _linkperson;

        public static QueryColumn _LinkPerson = new QueryColumn("LinkPerson", DbType.String);
        /// <summary>
        /// 联系人
        /// </summary>		
        [FieldMapping("LinkPerson")]
        public string LinkPerson
        {
            get
            {
                return _linkperson;
            }
            set
            {
                if (_linkperson != value)
                {
                    base.OnPropertyChanged("LinkPerson", _linkperson, value);
                    _linkperson = value;
                }
            }
        }

        private string _linkpersonmobile;

        public static QueryColumn _LinkPersonMobile = new QueryColumn("LinkPersonMobile", DbType.String);
        /// <summary>
        /// 联系人电话
        /// </summary>		
        [FieldMapping("LinkPersonMobile")]
        public string LinkPersonMobile
        {
            get
            {
                return _linkpersonmobile;
            }
            set
            {
                if (_linkpersonmobile != value)
                {
                    base.OnPropertyChanged("LinkPersonMobile", _linkpersonmobile, value);
                    _linkpersonmobile = value;
                }
            }
        }

        private string _orgid;

        public static QueryColumn _OrgID = new QueryColumn("OrgID", DbType.String);
        /// <summary>
        /// 机构代码
        /// </summary>		
        [FieldMapping("OrgID")]
        public string OrgID
        {
            get
            {
                return _orgid;
            }
            set
            {
                if (_orgid != value)
                {
                    base.OnPropertyChanged("OrgID", _orgid, value);
                    _orgid = value;
                }
            }
        }
        private string _orgName;
        [FieldMapping("OrgFullName","TU_Org","OrgID","OrgID")]
        [SqlBehavior(BindingFlags= ClauseBindingFlags.Select)]
        public string OrgFullName
        {
            get
            {
                return _orgName;
            }
            set
            {
                if (_orgName != value)
                {
                    base.OnPropertyChanged("OrgFullName", _orgName, value);
                    _orgName = value;
                }
            }
        }
        #endregion
    }
}
